/**
 * Copyright - Accor - All Rights Reserved www.accorhotels.com
 */
package com.my.imq.business.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.googlecode.genericdao.search.Search;
import com.my.imq.dao.DestinationDao;
import com.my.imq.model.Destination;
import com.my.imq.business.DestinationService;

/**
 * @author <a href="MABDELOUHAB">MABDELOUHAB</a>
 * created 25 janv. 2013
 * @since 
 * @version $Id$
 */
@Transactional
@Service(value="destinationService")
public class DestinationServiceImpl
    implements DestinationService
{
    @Autowired
    DestinationDao destinationDao;

    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#persist(com.hamada.imq.model.Broker)
     */
    public void persist( Destination destination )
    {
        if ( destination.getName() != null )
        {
            Destination d = destinationDao.searchUnique( new Search().addFilterEqual( "name", destination.getName() ) );
            if ( d == null )
            {
                destinationDao.persist( destination );
            }
        }

    }

    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#findAll()
     */
    public List<Destination> findAll()
    {
        return destinationDao.findAll();
    }

    /* (non-Javadoc)
     * @see com.hamada.imq.service.BrokerService#flush()
     */
    public void flush()
    {
        destinationDao.flush();
    }

    /**
     * @param brokerDao the brokerDao to set
     */
    public void setBrokerDao( DestinationDao destinationDao )
    {
        this.destinationDao = destinationDao;
    }

}
